import React, {Component, lazy, Suspense} from 'react';
import {Route} from 'react-router-dom'
import Header from "../Header";
import MyNavLink from "../MyNavLink";

const Home = lazy(() => import('./Home'))
const About = lazy(() => import('./About'))

class Index extends Component {

    render() {
        return (
            <div>
                <Header/>
                <div className="row">
                    <div className="col-xs-2 col-xs-offset-2">
                        <div className="list-group">
                            {/*<a className="list-group-item" href="./about.html">About</a>
                            <a className="list-group-item active" href="./home.html">Home</a>*/}
                            {/*activeClassName="active" 点击样式——默认active*/}
                            <MyNavLink to='/about'>About</MyNavLink>
                            <MyNavLink to='/home'>Home</MyNavLink>
                        </div>
                    </div>
                    <div className="col-xs-6">
                        <div className="panel">
                            <div className="panel-body">
                                <Suspense fallback={<h1>loading</h1>}>
                                    <Route path='/about' component={About}/>
                                    <Route path='/home' component={Home}/>
                                </Suspense>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

export default Index;